package com.dainel.mybatis.demo.bean;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.io.Serializable;
import java.util.Date;

@MappedSuperclass//该注解用于超类 则其子类表中会被自动注入该超类的所有属性
public class BaseBean implements Serializable {

    @CreationTimestamp
    @TableField(value = "create_time", fill = FieldFill.INSERT_UPDATE)
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'")
    private Date createTime;

    @TableField(value = "update_time", fill = FieldFill.UPDATE)
    @Column(name = "update_time", columnDefinition = "datetime comment '上次修改时间'")
    @UpdateTimestamp
    private Date updateTime;

    @Version
    @TableField(value = "version")
    @com.baomidou.mybatisplus.annotation.Version
    @Column(name = "version", columnDefinition = "bigint comment '该字段当前修改版本'")
    private long version;

//    @ApiModelProperty("是否已删除(不会传递到前端)")
//    @JsonIgnore
//    @TableField(value = "gs_delete", property = "'delete'")
//    @Column(name = "gs_delete", columnDefinition = "tinyint comment '是否已删除(不会传递到前端)'")
//    private boolean delete = false;     // 是否已删除(采用逻辑删除)

}
